//
//  CarResMode.m
//  CarTown
//
//  Created by xionghao on 15/8/19.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "CarResMode.h"
#import "CarbrandModel.h"
@implementation CarResMode
+(instancetype)carResWithDict:(NSDictionary *)dict{
    CarResMode *carmode=[[CarResMode alloc]init];
    [carmode setValuesForKeysWithDictionary:dict];
    NSMutableArray *mdata=[NSMutableArray array];
    NSArray *dataarray=dict[@"data"];
    if (![dataarray isKindOfClass:[NSNull class]]) {
        for (NSDictionary *dict in dataarray) {
            CarbrandModel *carbarndmodel=[CarbrandModel modeWithDict:dict];
            [mdata addObject:carbarndmodel];
        }
    }
    
    NSArray *resultArray = [mdata sortedArrayUsingComparator:^NSComparisonResult(CarbrandModel *obj1, CarbrandModel *obj2) {
        
        return [obj1.brand_desc compare:obj2.brand_desc options:NSNumericSearch];
    }];
    carmode.data=resultArray;
    return carmode;
}
@end
